// pages/zx/zx.js
Page({
  data: {
    list:[],
    flList:[],
  },
  onLoad(e) {
    let index=e.index
    const app = getApp(); 
    console.log(app)
    console.log(getApp().globalData.fl_id)
    let id = getApp().globalData.fl_id;
    let flList=''
    this.setData({
      id:id,
    })
    console.log(id)
    console.log(index)
    wx.request({
      url: 'http://127.0.0.1:8080/zxfl',
      method: 'GET',
      success: res => {
        console.log(res)
        console.log(id)      
          flList=res.data.data[index].Zxe
       
        this.setData({
         flList:flList
        })
        console.log(this.data.flList)
      }
    })
  },
  tianjia(){
    let id= this.data.id
    wx.navigateTo({
      url: '/pages/tjzx/tjzx?id='+id,
    })
  },
  put(o){
    let id =o.target.dataset.id
    wx.navigateTo({
      url: '/pages/xgzx/xgzx?id='+id,
    })
  },
  del(o){
    let id =o.target.dataset.id
    console.log(id)
    wx.request({
      url: 'http://127.0.0.1:8080/zxdel/'+id,
      method:'DELETE',
      success: res => {
        console.log(res)
        if (res.statusCode == 200) {
          wx.showToast({
            title: '删除成功',
            icon: 'success'
          })
          wx.redirectTo({
            url: '/pages/zx/zx', // 替换为当前页面的路径
          });
        }
        if (res.statusCode == 500) {
          wx.showToast({
            title: '删除失败',
            icon: 'error'
          })
        }
      }
    })
  }
})

// wx.request({
//   url: 'http://127.0.0.1:8080/zxup'+id,
// })